package com.jt.sevrice;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.jt.dao.RightsMapper;
import com.jt.pojo.Rights;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class RightsServiceImpl implements RightsService{
    @Autowired
    private RightsMapper rightsMapper;
    @Override
    public List<Rights> getRightsList() {
        QueryWrapper<Rights>queryWrapper =new QueryWrapper<>();
        queryWrapper.eq("parent_id", 0);
        List<Rights>rightsList1=rightsMapper.selectList(queryWrapper);
        System.out.println(rightsList1);
        for (Rights rights : rightsList1) {
            QueryWrapper<Rights>queryWrappertwo= new QueryWrapper<>();
            queryWrappertwo.eq("parent_id", rights.getId());
            List<Rights> rightsList2 = rightsMapper.selectList(queryWrappertwo);
            rights.setChildren(rightsList2);
        }
        return rightsList1;
    }
}
